#!/bin/sh


tz='MSK-4MSK'
ttz=$( echo $tz | sed 's/\//\\\//' )
export TZ=$tz

case "$1" in
  start)
        echo -n "Crontab start ... "

        #patching profile
        sed -i "s/^\(export TZ=\).*$/\1$ttz/" /usr/local/etc/profile

        if [ -n "`/opt/bin/pidof cron`" ]; then 
          /opt/bin/killall cron 2>/dev/null
        fi
        /opt/sbin/cron
        if [ $? != 0 ] ; then
          echo "Fail"
        else
          echo "Done"
        fi
        ;;
  enable)
        ;;
  disable)
        #unpatching profile
        sed -i "s/^\(export TZ=\).*$/\1CST+0:00:00/" /usr/local/etc/profile
        ;;
  stop)
        if [ -n "`/opt/bin/pidof cron`" ]; then 
          /opt/bin/killall cron 2>/dev/null
        fi
        ;;
  status)
        ;;
  *)
        echo "Usage: $0 {start|stop|status|enable|disable}"
        ;;
esac

exit $?
